----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 22104 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 240
SPELL.m_sName = "Slash"
SPELL.m_sToolTip =	"Slash the target, dealing low damage and causing bleeding."
SPELL.m_sIcon = "devin/blackbetty/spells/rogue/slash.png"
SPELL.m_iCoolDown = 0.1
SPELL.m_iManaCost = 20
SPELL.m_bRequiresTarget = true
SPELL.m_iSpellType = SPELLTYPE_MAA
SPELL.m_bRecastWhileCasting = false

---------------------------------------------------------------------------------------

local range = 100

function SPELL:Cast( pl, target )
	
	print(self.m_sName)
	if(target && target:IsValid() && target != pl ) then
		pl.InSpellAnimation = true
		if(pl:IsPlayer())then
			pl:DoAnimationEvent(ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE)
		else
			pl:RestartGesture(ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE)
		end
		pl:EmitSound("devin/blackbetty/weapons/swing/1h_"..math.random(1,3)..".wav", 100, 100+math.random(-10,10))
		ParticleEffectAttach( "slash", PATTACH_POINT_FOLLOW, pl, pl:LookupAttachment("anim_attachment_RH"))
			timer.Simple(0.1, function()
				if(target and pl:GetPos():Distance(target:GetPos()) < self.m_iRange)then
					self:Effect(pl, target)
					--self:ApplySpellMods(self, pl, target)
				end
			end)
	end
end

function SPELL:Effect(pl, target)

	local weapon = nil
	if(pl:IsPlayer())then
		weapon = pl:GetWeapon("weapon_all")
	else
		target = pl.Target
	end
	pl:EmitSound("devin/blackbetty/weapons/hamstring/hamstring"..math.random(1,3)..".wav", 100, 60+math.random(-10,10))
	ParticleEffect( "pummel_hit", target:GetPos() + Vector(0, 0, 46) + (target:GetAngles():Forward()*6), Angle(0,0,0), pl )
	ParticleEffect( "player_blood", target:GetPos() + Vector(0, 0, 46) + (target:GetAngles():Forward()*6), Angle(0,0,0), pl )
	if(SERVER)then
		if(weapon)then
			self:DealDamage(weapon.MinWeaponDamage*0.75, weapon.MaxWeaponDamage*0.75, pl, target, DMG_GENERIC)
			AddEffect(target, 4, "SlashDoT", {pl, DMG_SLASH}, 2, 3, 3)
		else
			self:DealDamage(pl.MinDamage*1, pl.MaxDamage*1, pl, target, DMG_GENERIC)
		end
	end
end




